<template>
  <div id="wrapper" >
    <nav v-if="loged" class="navbar navbar-default top-navbar" role="navigation">
      <div class="navbar-header">
        <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".sidebar-collapse">
          <span class="sr-only">Toggle navigation</span>
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
        </button>
        <a class="navbar-brand" href="index.html">课程后台</a>
      </div>

      <ul class="nav navbar-top-links navbar-right">
        <li class="dropdown">
          <a class="dropdown-toggle" data-toggle="dropdown" href="#" aria-expanded="false">
            <i class="fa fa-envelope fa-fw"></i> <i class="fa fa-caret-down"></i>
          </a>
          <ul class="dropdown-menu dropdown-messages">
            <li>
              <a href="#">
                <div>
                  <strong>John Doe</strong>
                  <span class="pull-right text-muted">
                                        <em>Today</em>
                                    </span>
                </div>
                <div>Lorem Ipsum has been the industry's standard dummy text ever since the 1500s...</div>
              </a>
            </li>
            <li class="divider"></li>
            <li>
              <a href="#">
                <div>
                  <strong>John Smith</strong>
                  <span class="pull-right text-muted">
                                        <em>Yesterday</em>
                                    </span>
                </div>
                <div>Lorem Ipsum has been the industry's standard dummy text ever since an kwilnw...</div>
              </a>
            </li>
            <li class="divider"></li>
            <li>
              <a href="#">
                <div>
                  <strong>John Smith</strong>
                  <span class="pull-right text-muted">
                                        <em>Yesterday</em>
                                    </span>
                </div>
                <div>Lorem Ipsum has been the industry's standard dummy text ever since the...</div>
              </a>
            </li>
            <li class="divider"></li>
            <li>
              <a class="text-center" href="#">
                <strong>Read All Messages</strong>
                <i class="fa fa-angle-right"></i>
              </a>
            </li>
          </ul>
          <!-- /.dropdown-messages -->
        </li>
        <!-- /.dropdown -->
        <li class="dropdown">
          <a class="dropdown-toggle" data-toggle="dropdown" href="#" aria-expanded="false">
            <i class="fa fa-tasks fa-fw"></i> <i class="fa fa-caret-down"></i>
          </a>
          <ul class="dropdown-menu dropdown-tasks">
            <li>
              <a href="#">
                <div>
                  <p>
                    <strong>Task 1</strong>
                    <span class="pull-right text-muted">60% Complete</span>
                  </p>
                  <div class="progress progress-striped active">
                    <div class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="60"
                         aria-valuemin="0" aria-valuemax="100" style="width: 60%">
                      <span class="sr-only">60% Complete (success)</span>
                    </div>
                  </div>
                </div>
              </a>
            </li>
            <li class="divider"></li>
            <li>
              <a href="#">
                <div>
                  <p>
                    <strong>Task 2</strong>
                    <span class="pull-right text-muted">28% Complete</span>
                  </p>
                  <div class="progress progress-striped active">
                    <div class="progress-bar progress-bar-info" role="progressbar" aria-valuenow="28" aria-valuemin="0"
                         aria-valuemax="100" style="width: 28%">
                      <span class="sr-only">28% Complete</span>
                    </div>
                  </div>
                </div>
              </a>
            </li>
            <li class="divider"></li>
            <li>
              <a href="#">
                <div>
                  <p>
                    <strong>Task 3</strong>
                    <span class="pull-right text-muted">60% Complete</span>
                  </p>
                  <div class="progress progress-striped active">
                    <div class="progress-bar progress-bar-warning" role="progressbar" aria-valuenow="60"
                         aria-valuemin="0" aria-valuemax="100" style="width: 60%">
                      <span class="sr-only">60% Complete (warning)</span>
                    </div>
                  </div>
                </div>
              </a>
            </li>
            <li class="divider"></li>
            <li>
              <a href="#">
                <div>
                  <p>
                    <strong>Task 4</strong>
                    <span class="pull-right text-muted">85% Complete</span>
                  </p>
                  <div class="progress progress-striped active">
                    <div class="progress-bar progress-bar-danger" role="progressbar" aria-valuenow="85"
                         aria-valuemin="0" aria-valuemax="100" style="width: 85%">
                      <span class="sr-only">85% Complete (danger)</span>
                    </div>
                  </div>
                </div>
              </a>
            </li>
            <li class="divider"></li>
            <li>
              <a class="text-center" href="#">
                <strong>See All Tasks</strong>
                <i class="fa fa-angle-right"></i>
              </a>
            </li>
          </ul>
          <!-- /.dropdown-tasks -->
        </li>
        <!-- /.dropdown -->
        <li class="dropdown">
          <a class="dropdown-toggle" data-toggle="dropdown" href="#" aria-expanded="false">
            <i class="fa fa-bell fa-fw"></i> <i class="fa fa-caret-down"></i>
          </a>
          <ul class="dropdown-menu dropdown-alerts">
            <li>
              <a href="#">
                <div>
                  <i class="fa fa-comment fa-fw"></i> New Comment
                  <span class="pull-right text-muted small">4 min</span>
                </div>
              </a>
            </li>
            <li class="divider"></li>
            <li>
              <a href="#">
                <div>
                  <i class="fa fa-twitter fa-fw"></i> 3 New Followers
                  <span class="pull-right text-muted small">12 min</span>
                </div>
              </a>
            </li>
            <li class="divider"></li>
            <li>
              <a href="#">
                <div>
                  <i class="fa fa-envelope fa-fw"></i> Message Sent
                  <span class="pull-right text-muted small">4 min</span>
                </div>
              </a>
            </li>
            <li class="divider"></li>
            <li>
              <a href="#">
                <div>
                  <i class="fa fa-tasks fa-fw"></i> New Task
                  <span class="pull-right text-muted small">4 min</span>
                </div>
              </a>
            </li>
            <li class="divider"></li>
            <li>
              <a href="#">
                <div>
                  <i class="fa fa-upload fa-fw"></i> Server Rebooted
                  <span class="pull-right text-muted small">4 min</span>
                </div>
              </a>
            </li>
            <li class="divider"></li>
            <li>
              <a class="text-center" href="#">
                <strong>See All Alerts</strong>
                <i class="fa fa-angle-right"></i>
              </a>
            </li>
          </ul>
          <!-- /.dropdown-alerts -->
        </li>
        <!-- /.dropdown -->
        <li class="dropdown">
          <a class="dropdown-toggle" data-toggle="dropdown" href="#" aria-expanded="false">
            <i class="fa fa-user fa-fw"></i> <i class="fa fa-caret-down"></i>
          </a>
          <ul class="dropdown-menu dropdown-user">
            <li><a href="#"><i class="fa fa-user fa-fw"></i> User Profile</a>
            </li>
            <li><a href="#"><i class="fa fa-gear fa-fw"></i> Settings</a>
            </li>
            <li class="divider"></li>
            <li><a @click="removeUser"><i class="fa fa-sign-out fa-fw"></i> Logout</a>
            </li>
          </ul>
          <!-- /.dropdown-user -->
        </li>
        <!-- /.dropdown -->
      </ul>
    </nav>
    <!--/. NAV TOP  -->
    <nav v-if="loged" class="navbar-default navbar-side" role="navigation">
      <div class="sidebar-collapse">
        <ul class="nav" id="main-menu">

          <li class="cursor-pointer">
            <a :class="{'active-menu':nowPath==='/'}" class="" @click="jumpTo('Index')"><i class="fa fa-dashboard"></i> Dashboard</a>
          </li>
<!--          <li>-->
<!--            <a href="ui-elements.html"><i class="fa fa-desktop"></i> UI Elements</a>-->
<!--          </li>-->
<!--          <li>-->
<!--            <a href="chart.html"><i class="fa fa-bar-chart-o"></i> Charts</a>-->
<!--          </li>-->
<!--          <li>-->
<!--            <a href="tab-panel.html"><i class="fa fa-qrcode"></i> Tabs & Panels</a>-->
<!--          </li>-->

          <li class="cursor-pointer" @click="jumpTo('curriculumSeries')">
            <a :class="{'active-menu':nowPath.indexOf('/Curriculum')!==-1}"><i class="fa fa-table"></i> 课程管理</a>
          </li>
          <li class="cursor-pointer" @click="jumpToByPath('/HomeWork')">
            <a :class="{'active-menu':nowPath.indexOf('/HomeWork')!==-1}"><i class="fa fa-edit"></i> 作业管理 </a>
          </li>
          <li class="cursor-pointer" @click="jumpTo('Discuss')">
            <a :class="{'active-menu':nowPath.indexOf('/Discuss')!==-1}"><i class="fa fa-edit"></i> 讨论管理 </a>
          </li>
          <li class="cursor-pointer" @click="jumpToByPath('/student')">
            <a :class="{'active-menu':nowPath.indexOf('/student')!==-1}"><i class="fa fa-edit"></i> 学生管理 </a>
          </li>

<!--          <li>-->
<!--            <a href="#"><i class="fa fa-sitemap"></i> Multi-Level Dropdown<span class="fa arrow"></span></a>-->
<!--            <ul class="nav nav-second-level">-->
<!--              <li>-->
<!--                <a href="#">Second Level Link</a>-->
<!--              </li>-->
<!--              <li>-->
<!--                <a href="#">Second Level Link</a>-->
<!--              </li>-->
<!--              <li>-->
<!--                <a href="#">Second Level Link<span class="fa arrow"></span></a>-->
<!--                <ul class="nav nav-third-level">-->
<!--                  <li>-->
<!--                    <a href="#">Third Level Link</a>-->
<!--                  </li>-->
<!--                  <li>-->
<!--                    <a href="#">Third Level Link</a>-->
<!--                  </li>-->
<!--                  <li>-->
<!--                    <a href="#">Third Level Link</a>-->
<!--                  </li>-->

<!--                </ul>-->

<!--              </li>-->
<!--            </ul>-->
<!--          </li>-->
<!--          <li>-->
<!--            <a href="empty.html"><i class="fa fa-fw fa-file"></i> Empty Page</a>-->
<!--          </li>-->
        </ul>

      </div>

    </nav>
    <!-- /. NAV SIDE  -->
    <router-view/>
  </div>
</template>

<style>

</style>

<script>

import $store from "./store/index";
import axios from "axios";
import { computed, onMounted } from "vue";
export default {

  name: 'app',
  computed: {},
  setup(){
    // 获取state.loged
    let loged = computed(()=>{ return $store.state.loged });
    function setLoged(log) {
      console.log("sert")
      $store.dispatch('setLog',log);
    }
    return{
      setLoged,
      loged
    }
  },
  created() {

    var parse = JSON.parse(window.localStorage.getItem('zjxClass_teacherinfo'));
    if (parse){
      axios.post("/api/open/CheckLogStatus",{
        Token:parse.Token
      })
    }else {
      axios.post("/api/open/CheckLogStatus",{
        Token:'no'
      })
    }

  },
  data() {
    return {
      nowPath:''
    }
  },
  methods: {
    jumpTo: function (name) {
      this.$router.push({name: name})
    },
    jumpToByPath: function (path) {
      this.$router.push({path: path})
    },
    checkWhetherOnline(token){

    },
    removeUser: function () {
      window.localStorage.removeItem("zjxClass_teacherinfo");
      this.jumpTo('login')
      this.setLoged(false)
    }
  },
  watch:{
    $route(to,from){
      this.nowPath = to.path
    }
  }

}
</script>
